package com.yuebook.smartrpc.framework.serialization.common;

import org.apache.commons.lang3.StringUtils;

/**
 * @author honglei
 * @date 2018/11/16 下午4:57
 */
public enum SerializerType {

    SERIALIZER_DEFAULTJAVA("defaultjava"),
    SERIALIZER_FASTJSON("fastjson"),
    SERIALIZER_HESSIAN("hessian"),
    SERIALIZER_PROTOSTUFF("protostuff"),
    ;

    private String displayName;

    SerializerType(String displayName) {
        this.displayName = displayName;
    }

    public String getDisplayName() {
        return displayName;
    }

    public static SerializerType queryType(String displayName) {
        if (StringUtils.isBlank(displayName)) {
            return SERIALIZER_PROTOSTUFF;
        }
        for (SerializerType type : SerializerType.values()) {
            if (displayName.equals(type.getDisplayName())) {
                return type;
            }
        }
        return null;
    }
}
